package main

import (
	"fmt"
	"github.com/golang/glog"
	"net/http"
	"os"
)

func main() {
	glog.V(2).Info("go go go!")
	mux := http.NewServeMux()
	mux.HandleFunc("/yys", yys)
	mux.HandleFunc("/healthz", healthz)

	server := &http.Server{
		Addr: "127.0.0.1:8080",
		Handler: mux,
	}

	err := server.ListenAndServe()
	if err != nil {
		return
	}
}

func healthz(writer http.ResponseWriter, request *http.Request) {
	writer.WriteHeader(200)
	writer.Write([]byte("200"))

}

func yys(writer http.ResponseWriter, request *http.Request) {
	for k, v := range request.Header {
		for _, n := range v {
			writer.Header().Set(k, n)
		}
	}
	version := os.Getenv("GOVERSION")
	writer.Header().Set("GOVERSION", version)
	writer.WriteHeader(201)
	fmt.Printf("request ip: %s, request status: %d\n", request.Host, 201)
}


